package utils

import (
	"path/filepath"
	"runtime"
	"strings"
)

func GetCaller(stackLevel int) (fileName string, line int, funcName string) {
	pc, file, line, ok := runtime.Caller(stackLevel + 1)
	if !ok {
		return "", 0, ""
	}
	funcInfo := runtime.FuncForPC(pc)
	if funcInfo == nil {
		return "", 0, ""
	}
	name := filepath.Ext(funcInfo.Name())
	return file, line, strings.TrimLeft(name, ".")
}
